import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void testInsert(int[] array) {
        int[] tmpArray=Arrays.copyOf(array,array.length);//测试互不干扰
        long startTime=System.currentTimeMillis();
        Sort.insertSort(tmpArray);
        long endTime=System.currentTimeMillis();
        System.out.println("直接插入排序耗时"+(endTime-startTime));
    }
    public static void testShellSort(int[] array) {
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.shellSort(tmpArray);
        long endTime=System.currentTimeMillis();
        System.out.println("希尔排序耗时"+(endTime-startTime));
    }

    public static void testSelectSort(int[] array) {
        int[] tmpArray=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        Sort.selectSort(tmpArray);
        long endTime=System.currentTimeMillis();
        System.out.println("选择排序耗时"+(endTime-startTime));
    }
    public static void initOrder(int[] array) {
        //数据逆序初始化
        for (int i = 0; i < array.length ; i++) {
            array[i]= array.length-i;
        }
    }

    public static void notOrder(int[] array) {
        Random random=new Random();
        for (int i = 0; i < array.length ; i++) {
            array[i]= random.nextInt(10000);
        }
    }
    public static void main3(String[] args) {
        int[] array=new int[1_0000];//测试足够大的数据
        initOrder(array);
        notOrder(array);
        testInsert(array);
        //testShellSort(array);
        testSelectSort(array);
    }
    public static void main(String[] args) {
        int[] array={1,6,34,58,44,9};
        //Sort.insertSort(array);
        //Sort.selectSort2(array);
        //Sort.heapSort(array);
        Sort.bubbleSort(array);
        System.out.println(Arrays.toString(array));
    }



}
